﻿package com.vicentediaz.data
{
    import com.vicentediaz.data.events.*;
    import flash.events.*;
    import flash.net.*;

    public class DAO extends EventDispatcher
    {
        public var gallery:XML;
        public var sounds:XML;
        private static var instance:DAO;

        public function DAO(param1:IEventDispatcher = null)
        {
            super(param1);
            return;
        }// end function

        private function onSoundsXMLLoaded(param1:Event) : void
        {
            this.sounds = XML(param1.target.data);
            dispatchEvent(new DAOEvent(DAOEvent.SOUNDS_LOADED));
            return;
        }// end function

        private function onGalleryXMLLoaded(param1:Event) : void
        {
            this.gallery = XML(param1.target.data);
            dispatchEvent(new DAOEvent(DAOEvent.GALLERY_LOADED));
            return;
        }// end function

        public function loadGalleryXML() : void
        {
            var _loc_1:* = new URLLoader(new URLRequest(Config.getInstance().getByValue("XML_GALLERY_PATH")));
            _loc_1.addEventListener(Event.COMPLETE, this.onGalleryXMLLoaded, false, 0, true);
            return;
        }// end function

        public function loadSoundsXML() : void
        {
            var _loc_1:* = new URLLoader(new URLRequest(Config.getInstance().getByValue("XML_SOUNDS_PATH")));
            _loc_1.addEventListener(Event.COMPLETE, this.onSoundsXMLLoaded, false, 0, true);
            return;
        }// end function

        public static function getInstance() : DAO
        {
            instance = instance ? (instance) : (new DAO);
            return instance;
        }// end function

    }
}
